﻿using System;
using System.Data;
using System.Collections.Generic;

using System.Text;
using TimKen.DataEntity;

namespace TimKen.BussLogic
{
    /// <summary>
    /// 前台注册用户业务逻辑操作类
    /// </summary>
    public class WebUserManager
    {
        private readonly TimKen.DataAccess.WebUserDAO dal = new TimKen.DataAccess.WebUserDAO();
        public WebUserManager()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string UserName)
        {
            return dal.Exists(UserName);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(TimKen.DataEntity.WebUser model)
        {
            if (UserFacade.Exists(model.UserName))
            {
                throw new TimKen.DataEntity.CstmException("Exists UserName");
            }
            else
            {
                dal.Add(model);
            }
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TimKen.DataEntity.WebUser model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(string UserID)
        {

            dal.Delete(UserID);
        }

        public UserS Login(string username, string password)
        {
            return dal.Login(username, password);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TimKen.DataEntity.WebUser GetModel(string UserName)
        {

            return dal.GetModel(UserName);
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetPageList(int PageSize, int PageIndex, string UserName, string RealName, string Company)
        {
            return dal.GetList(PageSize, PageIndex, UserName, RealName, Company);
        }


        public bool IsAuthenticatedUser(string username)
        {
            return dal.IsAuthenticatedUser(username);
        }

        public bool AuthenticatedUser(string username) 
        {
            return dal.AuthenticatedUser(username);
        }
        #endregion  成员方法
    }
}

